package com.sgb.knowledgeshare.viewmodel;

import androidx.lifecycle.ViewModel;

import com.sgb.knowledgeshare.ShareConfig;
import com.sgb.knowledgeshare.view.activity.ShareUserVideoInfoActivity;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.util.MToast;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by：PC0033 on 2020/9/27 10:34
 */
public class ShareUserVideoInfoModel extends ViewModel {

    ShareUserVideoInfoActivity shareuservideoinfoactivity;
    public void setActivity(ShareUserVideoInfoActivity shareUserVideoInfoActivity) {
        shareuservideoinfoactivity = shareUserVideoInfoActivity;
    }
    //    删除视频的操作
    public void deleteMyVideo(List<Long> delectList) {
        DialogHelper.showProgressDialog(shareuservideoinfoactivity, null, "删除中...", 0, true, null).setCanceledOnTouchOutside(false);
        ShareConfig.getInstance().getApi().getDeleteMyVideo(delectList).enqueue(new ICallBack<BaseEntity>() {
            @Override
            public void onSuccess(BaseEntity data) {
                DialogHelper.dismissProgressDialog();
                if (data.getData() == null) {
                    return;
                }
                if (data.getState().equals(ShareConfig.RESPONSE_OK)) {
                    MToast.showToast(shareuservideoinfoactivity.getActivity(), "删除视频成功！");
                    shareuservideoinfoactivity.finish();
                } else {
                    MToast.showToast(shareuservideoinfoactivity.getActivity(), data.getMsg());
                }
            }
        });
    }


}
